//
//  demo2View.m
//  MyBlock
//
//  Created by YuanJiang on 2019/9/4.
//  Copyright © 2019 YuanJiang. All rights reserved.
//

#import "demo2View.h"

@implementation demo2View

-(instancetype)initWithTitle:(NSString *)title
               complateBlock:(void(^)(NSString *))blcok
{
    if (self = [super init]) {
        self.value = ^(NSString * _Nonnull value) {
            blcok(value);
        };
        [self setUI];
    }
    return self;
}

-(void)setUI
{
    [self setFrame:CGRectMake(100, 100, [UIScreen mainScreen].bounds.size.width-200, 400)];
    [self setBackgroundColor:[UIColor redColor]];
    
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    //将当前控制器类名传过去
    __weak typeof(self)weakself = self;
    if (weakself.value) {
        weakself.value(NSStringFromClass([weakself class]));
    }
    [self removeFromSuperview];
}

@end
